﻿

namespace YiShop.System.Repositories
{
    public class SysNoticeRepository : BaseRepository<SysNotice, SysNoticeDto>
    {
        public SysNoticeRepository(ISqlSugarRepository<SysNotice> sqlSugarRepository) : base(sqlSugarRepository)
        {
        }

        public override ISugarQueryable<SysNoticeDto> DtoQueryable(SysNoticeDto dto)
        {
            return Repo.AsQueryable()
                .WhereIF(dto.NoticeId > 0, (t) => t.NoticeId == dto.NoticeId)
                .Select((t) => new SysNoticeDto
                {
                    NoticeContent = SqlFunc.MappingColumn(t.NoticeContent, " cast(notice_content as char) ")
                }, true);
        }

        public override ISugarQueryable<SysNotice> Queryable(SysNoticeDto dto)
        {
            return Repo.AsQueryable()
                .WhereIF(dto.NoticeId > 0, (t) => t.NoticeId == dto.NoticeId);
        }
    }
}